var todolist = document.querySelector("#todolist");
var olf = document.querySelector("#olf");
var op = document.querySelector("#anniu");

op.addEventListener("click",function(){
    if (olf.value == ""){
        alert("输入内容不能为空")
    }else {
        var new_jb = document.createElement("li");
        var yuan = document.createElement("span");
        var dui = document.createElement("i");
        var shan = document.createElement("em") ;
        todolist.appendChild(new_jb);
        new_jb.innerHTML = olf.value;
        new_jb.appendChild(yuan);
        yuan.appendChild(dui);
        dui.style.display = "none";
        new_jb.appendChild(shan);
        shan.className = "far fa-trash-alt";
        dui.className = "fas fa-check" ;
        dui.style.zIndex = "1";
        olf.value = "";
        /*删除*/
        shan.onclick = function(){
            this.parentElement.parentElement.removeChild(this.parentElement)
        }
    }
    /*添加对号*/
    var b = true;
    yuan.onclick = function(){
        if (b) {
            dui.style.display = "block";
            new_jb.classList.add("sc");
        }else{
            dui.style.display = "none";
            new_jb.classList.remove("sc");
        }
        b =! b;
    }



});





















/*var input1 =document.querySelector("#ipt1");
 var text = document.querySelector("#text");
 var anniu = document.querySelector("#anniu");
 anniu.addEventListener("click",function(){
 //创建节点
 var new_obj = document.createElement("p");
 //创建任务内容节点
 var zi = document.createElement("a");
 //将input标签添加到
 zi.innerHTML = input1.value;
 //添加节点（删除的图片）
 var op = document.createElement("img");
 //添加完成任务的节点
 var dui = document.createElement("span");
 //将节点的图片引进过来
 op.setAttribute("src","img/img-1.png");
 //操作节点（删除）
 op.setAttribute("onclick","javascript:this.parentNode.parentNode.removeChild(this.parentNode);");
 var yi = 'yixuan';
 dui.addEventListener('click',function(){
 if(yi == 'yixuan'){
 yi = "wexian";
 }else {
 yi = "yixuan";
 }
 if(yi == 'yixuan'){
 dui.innerHTML = "√";
 zi.style.color = "#999";
 zi.style.textDecoration = "line-through";
 }else {
 dui.innerHTML = "";
 zi.style.color = "#000";
 zi.style.textDecoration = "none";
 }
 });
 //将节点在div的最后一个标签添加
 text.appendChild(new_obj);
 //p标签添加完成任务的样式
 new_obj.appendChild(dui);
 //p标签添加a标签任务内容
 new_obj.appendChild(zi);
 //将图片在节点p的最后一个标签添加删除
 new_obj.appendChild(op);
 //清除input的内容
 input1.value = '';
 });
 */